<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
         <a-row :gutter="24">
         <a-col :xl="4" :lg="4" :md="4" :sm="24">
            <a-form-item label="会员昵称">
              <a-input placeholder="请输入会员昵称" v-model="queryParam.nickName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="4" :lg="4" :md="4" :sm="24">
            <a-form-item label="手机号">
              <a-input placeholder="请输入手机号" v-model="queryParam.userPhone"></a-input>
            </a-form-item>
          </a-col>
            <a-col :xl="4" :lg="4" :md="4" :sm="24">
              <a-form-item label="优惠券名称">
                  <a-input placeholder="请输入优惠券名称" v-model="queryParam.couponName"></a-input>
              </a-form-item>
            </a-col>
          <a-col :xl="4" :lg="4" :md="4" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
         </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
         @change="handleTableChange"
        class="j-table-force-nowrap"
        >

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
      </a-table>
    </div>

    <adh-coupon-user-view-modal ref="modalForm" @ok="modalFormOk"></adh-coupon-user-view-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import AdhCouponUserViewModal from './modules/AdhCouponUserViewModal'

  export default {
    name: 'AdhCouponUserViewList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      AdhCouponUserViewModal
    },
    data () {
      return {
        description: 'adh_coupon_user_view管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'昵称',
            align:"center",
            dataIndex: 'nickName'
          },
            {
            title:'手机号',
            align:"center",
            dataIndex: 'userPhone'
          },
          {
            title:'头像',
            align:"center",
            dataIndex: 'userAvtor',
            scopedSlots: { customRender: 'imgSlot' }
          },
           {
            title:'券ID',
            align:"center",
            dataIndex: 'couponId'
          },
          {
            title:'券名称',
            align:"center",
            dataIndex: 'couponName'
          },
           {
            title:'浏览时间',
            align:"center",
            dataIndex: 'createTime'
          },
        ],
        url: {
          list: "/couponview/adhCouponUserView/list",
          delete: "/couponview/adhCouponUserView/delete",
          deleteBatch: "/couponview/adhCouponUserView/deleteBatch",
          exportXlsUrl: "/couponview/adhCouponUserView/exportXls",
          importExcelUrl: "couponview/adhCouponUserView/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'openId',text:'用户ID'})
        fieldList.push({type:'string',value:'couponName',text:'券名称'})
        fieldList.push({type:'string',value:'couponId',text:'券ID'})
        fieldList.push({type:'string',value:'nickName',text:'昵称'})
        fieldList.push({type:'string',value:'userPhone',text:'手机号'})
        fieldList.push({type:'string',value:'userAvtor',text:'头像'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>